//
//  WMRecordTableViewCell.swift
//  deWaterMarkingProject
//
//  Created by admin on 2025/9/9.
//

import UIKit

class WMRecordTableViewCell: UITableViewCell {

    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var dateLabel: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    var record: WMRecordModel? {
        didSet {
            if let record = record {
                if let data = UserDefaults.standard.object(forKey: record.image.or("")) as? Data {
                    iconImageView.image = UIImage(data: data)
                }else {
                    iconImageView.setImageUrl(record.image.or("").removingPercentEncoding)
                }
                titleLabel.text = record.title.or("")
                dateLabel.text = record.recordId.or("")
            }
        }
    }
}
